import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { NgxEchartsModule } from 'ngx-echarts';

import { SharedModule } from 'src/app/shared/shared.module';
import { AclGuard } from 'src/app/core/guard/acl.guard';
import { ROLE_LIST } from 'src/app/core/auth/role';

import { AssetsManagementComponent } from './pages/assets-management.component';
import { ResourceLocationComponent } from './pages/resource-location/resource-location.component';
import { LicenseComponent } from './pages/license/license.component';

// 路由配置
const routes: Routes = [
  {
    // 一级路由
    path: '', component: AssetsManagementComponent,
    // 二级路由
    children: [
      {
        path: '', component: ResourceLocationComponent,
        data: { breadcrumb: '资产定位' }
      },
      {
        path: 'resource-location', component: ResourceLocationComponent,
        data: { breadcrumb: '资产定位' }
      },
      {
        path: 'license', component: LicenseComponent,
        data: { roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec, ...ROLE_LIST.allDev], breadcrumb: '许可' },
        canActivate: [AclGuard]
      },
      {
        path: 'baseline', loadChildren: './pages/baseline/baseline.module#BaselineModule',
        data: { roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec, ...ROLE_LIST.allOp] },
        canActivate: [AclGuard]
      },
      {
        path: 'container', loadChildren: './pages/container/container.module#ContainerModule',
        data: { roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec, ...ROLE_LIST.allOp] },
        canActivate: [AclGuard]
      },
      {
        path: 'library', loadChildren: './pages/library/library.module#LibraryModule',
        data: { roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec, ...ROLE_LIST.allDev] },
        canActivate: [AclGuard]
      }
    ]
  },
];

@NgModule({
  // 导入路由配置和共享模版
  imports: [RouterModule.forChild(routes), SharedModule, NgxEchartsModule],
  declarations: [
    AssetsManagementComponent,
    ResourceLocationComponent,
    // ContainerComponent,
    LicenseComponent,
    // BaselineComponent,
    // ContainerDetailComponent,
  ]
})
export class AssetsManagementModule { }
